﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace psafth.RCTiming.Main.Pages.Dialogs
{
    /// <summary>
    /// Interaction logic for SelectHeat.xaml
    /// </summary>
    public partial class SelectHeatDialog : Window
    {
        private MainWindow _mainWindow;

        public SelectHeatDialog(Event ev, MainWindow mw)
        {
            if (mw == null)
                throw new ArgumentNullException("MainWindow has not been set");

            if (ev == null)
                throw new ArgumentNullException("Event object has not been set");

            this._mainWindow = mw;

            InitializeComponent();
            lbHeats.ItemsSource = ev.Heats.ToList();
        }

        private void btnHeat_Click(object sender, RoutedEventArgs e)
        {
            Button button = sender as Button;
            Heat heat = button.DataContext as Heat;

            if (heat != null)
                _mainWindow.MainFrame.Navigate(new Pages.RacePage(_mainWindow, heat));
        }

        private void btnCancel_Click(object sender, RoutedEventArgs e)
        {
            this.Close();
        }
    }
}
